﻿
namespace Sai.Test.TestDataBuilders
{
    using Sai.Core.Introspection;

    public class PropertyDeclarationBuilder
    {
		private string propertyName = string.Empty;
		private TypeName typeName = new TypeName();
        private bool isObsolete = false;
        private TypeName declaringType = new TypeName();
        private bool publicGetter = false;
        private bool publicSetter = false;

		public static PropertyDeclarationBuilder Property()
		{
			return new PropertyDeclarationBuilder();
		}

        public PropertyDeclarationBuilder Named(string name)
		{
            this.propertyName = name;
			return this;
		}

        public PropertyDeclarationBuilder OfType(string typeName)
        {
            this.typeName = new TypeName(new FullyQualifiedName(typeName));
            return this;
        }

        public PropertyDeclarationBuilder OfType(TypeName type)
		{
			this.typeName = type;
			return this;
		}

        public PropertyDeclarationBuilder IsObsolete()
        {
            this.isObsolete = true;
            return this;
        }

        public PropertyDeclarationBuilder InClass(string name)
		{
			this.declaringType = new TypeName(new FullyQualifiedName(name));
			return this;
		}

        public PropertyDeclarationBuilder InClass(TypeName type)
		{
			this.declaringType = type;
			return this;
		}

        public PropertyDeclarationBuilder WithPublicGetter()
        {
            this.publicGetter = true;
            return this;
        }

        public PropertyDeclarationBuilder WithPublicSetter()
        {
            this.publicSetter = true;
            return this;
        }

        public PropertyDeclaration Build()
		{
			return new PropertyDeclaration(
                this.propertyName, 
                this.typeName, 
                new ObsoleteMarker(this.isObsolete), 
                this.declaringType)
			{
				HasPublicGetter = this.publicGetter,
                HasPublicSetter = this.publicSetter
			};
		}

    }
}
